<template lang="html">

  <section class="detail">
    <Header>
      <mu-icon value="arrow_back" slot="left"  @touchend="back"></mu-icon>
      <span slot="title">产品详情</span>
    </Header>
    <h2>{{detail.title}}</h2>
    <hr/>
    <div class="subscription">
      <div v-html="detail.invest_income" class="sub"></div>
    </div>
    <div>
      <div class="four">
        <span class="sylx">{{detail.sylx}}</span>
        <span class="zqlx">{{detail.zqlx}}</span>
        <span class="xmlx">{{detail.xmlx}}</span>
        <span class="pay-way">{{detail.pay_way}}</span>
      </div>
    </div>
    <!-- 基本资料 -->
    <div class="basics">
      <div class="basics-up">
        <div class="basics-con">基本资料</div>
      </div>
      <hr/>
      <!-- 资料详情 -->
      <div class="basics-down">
        <div>
          <div>产品名称</div>
          <div class="rigth">{{detail.title}}</div>
        </div>
        <div>
          <div>评级等级</div>
          <div class="rigth">{{detail.rate_level}}</div>
        </div>
        <div>
          <div>评级说明</div>
          <div class="rigth">{{detail.rate_desc}}</div>
        </div>
        <div>
          <div>产品状态</div>
          <div class="rigth">{{detail.is_sale}}</div>
        </div>
        <div>
          <div>大小配比</div>
          <div class="rigth">全大额</div>
        </div>
        <div>
          <div>收益类型</div>
          <div class="rigth">{{detail.sylx}}</div>
        </div>
        <div>
          <div>发行机构</div>
          <div class="rigth">{{detail.issuer}}</div>
        </div>
        <div>
          <div>付息方式</div>
          <div class="rigth">{{detail.pay_way}}</div>
        </div>
        <div>
          <div>投资区域</div>
          <div class="rigth">{{detail.invest_area}}</div>
        </div>
        <div>
          <div>投资领域</div>
          <div class="rigth">{{detail.invest_field}}</div>
        </div>
        <div>
          <div>规模</div>
          <div class="rigth">{{detail.invest_total}}</div>
        </div>
        <div>
          <div>产品期限</div>
          <div class="rigth">{{detail.tzqx}}</div>
        </div>
        <div>
          <div>认购起点</div>
          <div class="rigth">{{detail.qtje_title}}</div>
        </div>
        <div>
          <div>本期起售日</div>
          <div class="rigth">{{detail.sale_start_time}}</div>
        </div>
        <div>
          <div>资质抵押</div>
          <div class="rigth">{{detail.asset_pledge}}</div>
        </div>
      </div>
    </div>

    <!-- 亮点 -->
    <div class="highlight a">
      <div class="highlight-up a-up">
        <p>亮点</p>
      </div>
      <hr/>
      <div v-html="detail.highlight" class="highlight-down a-down"></div>
    </div>
    <!-- 募集账号 -->
    <div class="bank_account a">
      <div class="bank_account-up a-up">
        <p>募集账号</p>
      </div>
      <hr/>
      <div v-html="detail.bank_account" class="bank_account-down a-down"></div>
    </div>
    <!-- 融资主体 -->
    <div class="finance_body a">
      <div class="finance_body-up a-up">
        <p>融资主体</p>
      </div>
      <hr/>
      <div v-html="detail.finance_body" class="finance_body-down a-down"></div>
    </div>
    <!-- 资金用途 -->
    <div class="finance_where a">
      <div class="finance_where-up a-up">
        <p>资金用途</p>
      </div>
      <hr/>
      <div v-html="detail.finance_where" class="finance_where-down a-down"></div>
    </div>
    <!-- 还款来源 -->
    <div class="finance_payback a">
      <div class="finance_payback-up a-up">
        <p>还款来源</p>
      </div>
      <hr/>
      <div v-html="detail.finance_payback" class="finance_payback-down a-down"></div>
    </div>
    <!-- 风控措施 -->
    <div class="finance_safe a">
      <div class="finance_safe-up a-up">
        <p>风控措施</p>
      </div>
      <hr/>
      <div v-html="detail.finance_safe" class="finance_safe-down a-down"></div>
    </div>
    <!-- 交易流程 -->
    <div class="deal a">
      <div class="deal-up a-up">
        <p>交易流程</p>
      </div>
      <hr/>
      <div class="deal-down">
        <!-- 预约 -->
        <div class="deal-content">
          <div class="deal-down-title">预约</div>
          <div class="deal-down-con">
            <p>实名预约产品</p>
            <p>额度确认，合同寄送给你</p>
          </div>
        </div>
        <!-- 打款 -->
        <div class="deal-content">
          <div class="deal-down-title">打款</div>
          <div class="deal-down-con">
            <p>进行打款，签署合同， 生成订单</p>
            <p style="color: #ff4081">个人提供资料：身份证、银行卡、打款凭条</p>
            <p style="color: #ff4081">机构提供资料：法人身份证、营业执照、开户许可证、打款凭条</p>
          </div>
        </div>
        <!-- 成立 -->
        <div class="deal-content">
          <div class="deal-down-title">成立</div>
          <div class="deal-down-con">
            <p>产品成立</p>
          </div>
        </div>
        <!-- 存续 -->
        <div class="deal-content">
          <div class="deal-down-title">续存</div>
          <div class="deal-down-con">
            <p>确认书发放</p>
          </div>
        </div>
      </div>
    </div>
    <div class="btn" @click="appointment">
      <span>直接预约</span>
    </div>
    <!-- 预约成功弹框 -->
    <mu-container>
      <mu-dialog title="" width="360" :open.sync="openSimple">
        该产品您已经预约过，我们会尽快安排专业理财经理跟您联系！
        <mu-button slot="actions" flat color="primary" @click="closeSimpleDialog">确定</mu-button>
      </mu-dialog>
    </mu-container>
    <!-- 预约弹框 -->
    <mu-container>
      <mu-dialog title="提示" width="600" max-width="80%" :esc-press-close="false" :overlay-close="false" :open.sync="openAlert">
        预约成功，请保持电话畅通，我们会尽快安排投资经理联系您。
        <mu-button slot="actions" flat color="primary" @click="closeSimpleDialog">取消</mu-button>
        <mu-button slot="actions" flat color="primary" @click="closeAlertDialog">确认</mu-button>
      </mu-dialog>
    </mu-container>
  </section>

</template>

<script lang="js">
import Header from "../components/Header.vue";
  export default  {
    //注册组件
    components: { Header },
    name: 'detail',
    props: [],
    mounted () {

    },
    data () {
      return {
        //数据
        detail: {},
        //选择框
        openAlert: false,
        //提示框
        openSimple: false
      }
    },
    //组件创建完成
    created() {
      //解构数据、
      let { params } = this.$route
      //发送请求
      this.$http
        .post('api/product/list', { params })
        //监听数据返回
        .then(({ data }) => {
          //根据params获取相应数据
          this.detail = data.data[params.id - 1];
        })
    },
    methods: {
      //预约理财师
      appointment() {
        //判断本产品store中product的状态
        let index = this.$store.state.product.findIndex(item => item.id === this.detail.id)
        //
        if(index < 0) {
            //如果不存在 则提示选择框
            this.openAlert = true;
          } else {
            //如果存在则出现提示框
            this.openSimple = true;
          }
      },
      //选择框确认效果
      closeAlertDialog () {
        this.openAlert = false;
        this.openSimple = false;
        //添加app属性
        this.$set(this.detail, 'app', false);
        //同步传递 添加预约
        this.$store.commit("addAppointmentData", this.detail)
      },
      //提示框隐藏
      closeSimpleDialog () {
        this.openSimple = false;
        this.openAlert = false;
      },
      // 后退
      back() {
        this.$router.go(-1);
      },
    },
    
    computed: {
      
    }
}


</script>

<style scoped lang="scss">
  .detail {
    background-color: #f7f7f7;
    .header {
      position: relative;
      .mu-icon {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
      }
      span {
        display: block;
        text-align: center;
      }
    }
    h2 {
      background-color: #fff;
      padding: 20px 10px;
      font-size: 16px;
      font-weight: 700;

    }
    .subscription {
      background-color: #fff;
      .sub {
       margin: 0px auto;
       padding: 10px 80px 0px; 
      }
    }
    .four {
      padding: 10px 5px;
      margin-bottom: 10px;
      background-color: #fff;
      span {
        display: inline-block;
        padding: 0 6px;
        height: 24px;
        line-height: 24px;
        font-size: 12px;
        border-radius: 4px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        white-space: nowrap;
        border: 1px solid #000;
        margin: 0px 1px;
      }
      .sylx {
        background-color: rgba(230,162,60,.1);
        border-color: rgba(230,162,60,.2);
        color: #e6a23c;
      }
      .zqlx {
        background-color: hsla(0,87%,69%,.1);
        border-color: hsla(0,87%,69%,.2);
        color: #f56c6c;
      }
      .xmlx {
        background-color: rgba(103,194,58,.1);
        border-color: rgba(103,194,58,.2);
        color: #67c23a;
      }
      .pay-way {
        background-color: hsla(0,87%,69%,.1);
        border-color: hsla(0,87%,69%,.2);
        color: #f56c6c;
      } 
    }
    .basics {
      margin-bottom: 10px;
      background-color: #fff;
      .basics-up {
        padding-left: 20px;
        .basics-con {
          &:before {
            content: "";
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: red;
            vertical-align: middle;
            position: relative;
            top: -2px;
            left: -4px;
          }
        }
      }
      .basics-down {
        font-size: 14px;
         div {
           padding: 1px 10px;
           color: #666;
           display: flex;
           div {
             flex: 1;
           }
           .rigth {
             color: black;
             display: flex;
             justify-content: flex-end;
             text-align: right;
           }
         }
      }
    }
    .highlight, .a {
      margin-bottom: 10px;
      background-color: #fff;
      .highlight-up, .a-up {
        padding: 10px 20px;
        p {
          &:before {
            content: "";
            display: inline-block;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: red;
            vertical-align: middle;
            position: relative;
            top: -2px;
            left: -4px;
          }
        }
      }
      .highlight-down, .a-down {
        padding: 5px 5px;
      }
    }
    .deal {
      margin-bottom: 60px;
      
      .deal-down {
        font-size: 12px;
        padding-top: 30px;
        padding-left: 20px;
        .deal-content {
          display: flex;
          .deal-down-title {
            width: 30px;
            margin-right: 20px;
          }
          .deal-down-con {
            flex: 1;
            padding-left: 30px;
            border-left: 1px solid #f00;
            position: relative;
            &:before {
              content: "";
              display: inline-block;
              width: 6px;
              height: 6px;
              border-radius: 50%;
              background: red;
              vertical-align: middle;
              position: relative;
              top: -2px;
              left: -4px;
              position: absolute;
              top: 8px;
            }
          }
          
        }
      }
    }
    .btn {
      background-color: #2196f3;
      color: #fff;
      text-align: center;
      font-size: 14px;
      height: 40px;
      line-height: 40px;
      position: fixed;
      bottom: 15px;
      left: 5px;
      right: 5px;
    }
  }
</style>
